#/*************************************************************************
#    > File Name: examples/example_ARCH.py
#    > Author: Yan Wang
#    > Mail: wangyan@imnu.edu.cn
#    > Created Time: 2022年06月29日 星期三 23时28分59秒
# ************************************************************************/
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.path.append('../Lib/')
from ARCH_Operation_bk import * 
from Exhibit import *

# Cal_Parton_Cut_Xection
cut_file_name="./examples/test_input/scan_run_[01-90]_cut.txt"
nocut_file_name="./examples/test_input/scan_run_[01-90]_no_cut.txt"
theoretical_parafile_name="./examples/test_input/data_grid_mh_mch.tsv"
cut_cross=Exhibit_Function(Cal_Parton_Cut_Xection,[cut_file_name, nocut_file_name, theoretical_parafile_name])




# param setting



# Replace_Para_in_ARCH
input_path_dict={"process":"{}",
	             "tmp" :"{}",
			     "file":"{}"}
origin_path_list={"process":"PROCESS          : sigh_w4b_{}",
					"tmp" :"RECORD_FILE      : 'tmp/sigh_w4b_{}.dat'",
					"file":"INPUT_FILE       : 'file_{}.dat'"}
input_file_dict={"file":"{}",
			     "cross":"{}"}
origin_file_list={"file":"FILE            : [\"/home/yancy/Software/ARCH_test/Auto_Running/output_data/input_events_mh_mch_20/tag_1_delphes_events_{}.root\"]",
					"cross":"CROSS_SECTION   : {}"}
input_path=[input_path_dict,origin_path_list]
input_file=[input_file_dict,origin_file_list]
input_para={"path":input_path, 
			"file":input_file}
cut_cross=[19.53, 66.25, 17.97, 0.6, 19.43]
results=Exhibit_Function(Replace_Para_in_ARCH,[input_para, cut_cross])


# Generate_Multi_ARCH_Control_File 
cut_cross=[19.53, 66.25, 17.97, 0.6, 19.43]

source = '/home/yancy/Software/ARCH_test/control/control_scan_4b0j_general'
target = '/home/yancy/Software/ARCH_test/control/control_scan_4b0j_mh_mch_20'
dir_name={"source":source,"target":target}


para_path={"origin": {"process":"PROCESS          : sigh_w4b_{}",
					"tmp" :"RECORD_FILE      : 'tmp/sigh_w4b_{}.dat'",
					"file":"INPUT_FILE       : 'file_{}.dat'"},
			"dict":{"process":"{}",
		             "tmp" :"{}",
				     "file":"{}"},
			"source":"path.dat",
			"labels":{"PROCESS          : sigh_w4b_1":0,
					"RECORD_FILE      : 'tmp/sigh_w4b_1.dat'":0,
					"INPUT_FILE       : 'file_sigh_w4b_1.dat'":0}
			}
file_folder_path="/home/yancy/Software/ARCH_test/Auto_Running/output_data/input_events_mh_mch_20/"
para_file={"origin": {"file":"FILE            : [\""+file_folder_path+"tag_1_delphes_events_{}.root\"]",
					"cross":"CROSS_SECTION   : {}"},
			"dict":{"file":"{}",
					"cross":"{}"},
			"source":"file.dat",
			"labels":{"FILE            : ['sig_Wh_4b_1_1.root']":0,
					"CROSS_SECTION   : 32.0566":0}
			}
input_para={"path":para_path, 
			"file":para_file}
Exhibit_Function(Generate_Multi_ARCH_Control_File,[cut_cross, dir_name,input_para])


# Find_ARCH_xection 
ARCH_out_name="./examples/test_input/ARCH_output/sigh_w4b_{}.dat"
total_file_num=5
ARCH_summary_folder="./examples/test_output/ARCH_xection_Summary/"
Exhibit_Function(Find_ARCH_xection, [ARCH_out_name,total_file_num, ARCH_summary_folder])



